/**
 * redis单例
 * @author xialeistudio
 * @date 2016/5/9 0009
 */
'use strict';
const redis = require('redis')
		, logger = require('./logger')
		, configManager = require('./config')
		, Promise = require('bluebird');
Promise.promisifyAll(redis.RedisClient.prototype);
Promise.promisifyAll(redis.Multi.prototype);
const client = redis.createClient(configManager.loadConfig().redis);
client.on('connect', ()=> {
	logger.info('[Redis] initialized');
});
client.on('error', (e)=> {
	logger.error('[Redis] ' + e.message);
});
module.exports = function() {
	return client;
};